<!DOCTYPE html >
<html>
<head>
    <meta name="Generator" content="ECSHOP v2.7.3" />
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>密码找回  </title>  <link rel="icon" href="/template/pc1/images/wmh_favicon.ico" type="image/x-icon" />
    <meta name="Keywords" content="" />
    <meta name="Description" content="" />
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
    <link rel="stylesheet" href="/template/default/css/public.css">
    <link rel="stylesheet" href="/template/default/css/loginxin.css">
    <script type="text/javascript" src="https://static.9hive.cn/global/vendor/jquery/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="https://static.9hive.cn/global/vendor/layer/layer.js"></script>
    <style>
        .ng_form dl {
             width: auto;
             float: none;
            padding: 0 20px;
            overflow: hidden;
            border-bottom: 1px solid #ddd;
        }
        .captcha{
            /* background-color: #47B9CA; */
            width: 76px!important;
            border-radius: 5px!important;
            border: solid 1px #ff673c !important;
            text-align: center!important;
            /*position: fixed!important;*/
            right: 26px!important;
            margin-top: 7px!important;
            line-height: 2.0!important;
            color: #ff673c!important;
        }
        .button{
            text-align: center;
        }
    </style>
</head>
<body>
<div class="tab_nav">
    <div class="header">
        <div class="h-left"><a class="sb-back" href="javascript:history.back(-1)" title="返回"><img src="/template/default/images/arrow_left_white.png"/></a></div>
        <div class="h-mid">密码找回</div>
    </div>
</div>

<form action="" method="post"autocomplete="off" onsubmit="return checkInfo(this);">
    <div class="layout">
        <div class="ng_form" id="form-area">
            <form action="user.php" method="post" class="c-form login-form">
                <input type="hidden" name="shopId"  value="${shopId!}"/>
                <dl id="enter_user" >
                    <dt>+86</dt> <dd><input type="text" name="phone" id="phone" placeholder="请输入手机号" class="enter-item "/><input type="text" name="phone" style="display: none" placeholder="请输入手机号" class="enter-item "/></dd><span id="username_notice"></span>
                </dl>
                <dl>
                    <dt>验证码</dt>
                    <dd style="min-width: 47%"><input name="phoneCaptcha" id="phoneCaptcha" class="enter-item " style="width: 100px" value="" placeholder="短信验证码" /><input name="phoneCaptcha" class=" "  value=""  style="display: none"/>

                    </dd>
                    <dt class="captcha" id="sendSms" onclick="send()">验证码</dt>
                    <span id="password_notice"></span>

                </dl>
                <dl>
                    <dt>新密码</dt>  <dd>
                    <input type="password" name="password" class="enter-item " style="display: none" placeholder="新密码" />
                    <input type="password" id="password" class="enter-item " value="" placeholder="新密码" />
                </dd><span id="conform_password_notice"> </span>

                </dl>
                <input readonly onclick="updatePassword()"  class="button orange" value="确认修改">
                <div class="third-area ">
                    <div class="third-area-a">
                        <a href="/b/customer/wapLogin?shopId=${shopId!}" class="button" >已注册？请登录</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</form>
</body>
<script type="text/javascript">
    function updatePassword() {
        var testphone = /^0?(13[0-9]|15[0-9]|17[0-9]|18[0-9]|14[57])[0-9]{8}$/;
        var phone = $("input[name='phone']").val();
        var phoneCaptcha=$("#phoneCaptcha").val();
        var password=$("#password").val();
        if (!testphone.test(phone)){
            layer.msg("请输入正确手机号!");
            return;
        }
        if(!phoneCaptcha){
            layer.msg("请输入短信验证码!");
            return;
        }

        if(!password){
            layer.msg("请输入新密码!");
            return;
        }

        $.ajax({
            url: "/b/password/updatePasswordByPhone",
            type: 'GET',
            data:{
                "phone": phone,
                "phoneCaptcha":phoneCaptcha,
                "password":password

            },
            success: function(data){
                if (data.state == 'ok'){
                    layer.msg("修改成功!");
                    setTimeout(function () {
                        window.location.href="/b/customer/wapLogin"
                    },1500);
                }else{
                    layer.msg(data.info);
                }
            }});


    }

    //发送验证码
    function send(){
        var testphone = /^0?(13[0-9]|15[0-9]|17[0-9]|18[0-9]|14[57])[0-9]{8}$/;
        var phone = $("input[name='phone']").val();
        if (!testphone.test(phone)){
            layer.msg("请输入正确手机号");
            return;
        }
        $.ajax({
            url: "/b/password/getCaptcha",
            type: 'GET',
            data:{
                "phone": phone
            },
            success: function(data){
                if (data.state == 'ok'){
                    layer.msg("验证码发送成功");
                    settime();
                }else{
                    layer.msg(data.info);
                }
            }});
    }
    var countdown=60;
    var timeid = 0;
    function settime() {
        if (countdown == 0) {
            $("#sendSms").attr("onclick","send();");
            $("#sendSms").html("验证码");
            clearTimeout(timeid);
            return;
        } else {
            $("#sendSms").removeAttr('onclick');
            $("#sendSms").html("(" + countdown + ")");
            countdown--;
        }
        timeid = setTimeout(function() {
            settime()
        },1000)
    }
</script>
</html>